<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    计数器1: <input type="button" value="1" data-counter />
    <hr />
    计数器2: <input type="button" value="2" />
    <script>
      document.onclick = function (e) {
        if (e.target.dataset.counter !== undefined) {
          e.target.value++;
        }
      };
    </script>
  </body>
</html>
